package com.SMP.service.class_room;

import com.SMP.dao.AttendanceMapper;
import com.SMP.model.Attendance;
import com.SMP.model.AttendanceExample;
import com.SMP.model.Course;
import com.SMP.model.People;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class AttendanceService {
    @Autowired
    AttendanceMapper attendanceMapper;

    /**
     * 增加考勤记录
     * @author WYHY
     *
     * */
    public int addAttendance(People people, Course course,String attendanceType){
        int result=0;
        Attendance attendance=new Attendance();
        attendance.setWeek(course.getWeek()+"");
        attendance.setLessonsId(course.getLessonsNo()+"");
        attendance.setGrade(people.getGrade());
        attendance.setClasss(people.getClasss());
        attendance.setTime(new Date());
        attendance.setName(people.getId());
        attendance.setProfessional(people.getProfessional());
        attendance.setAttendanceType(attendanceType);
        attendance.setReachState("3");
        attendance.setStandby1("1");
        result=attendanceMapper.insert(attendance);
        return result;
    }

    /**
     * 修改考勤记录
     * @author WYHY
     *
     * */
    public int updAttendance(Attendance attendance){
        int result=0;
        result=attendanceMapper.updateByExampleSelective(attendance,null);
        return result;
    }

    /**
     * 条件考勤记录
     * @author WYHY
     *
     * */
    public List<Attendance> selAttendance(Attendance attendance){
        List<Attendance> result=attendanceMapper.selectByAttendance(attendance);
        return result;
    }
    /**
     * @author TSY
    //  * @param 查询所有教师出勤记录
     */
    public List<Attendance> getTeaAll() {
        List<Attendance> list =attendanceMapper.selectAtt("1");
        return list;
    }
    /**
     * @author TSY
    //  * @param 按姓名查询单个教师出勤记录
     */
    public List<Attendance> getTeaByName(String name) {
        List<Attendance> list=attendanceMapper.selTeaByName(name);
        return list;
    }
    /**
     * @author TSY
    //  * @param 按照id查询单个教师出勤记录
     */
    public List<Attendance> getTeaById(String id) {
        List<Attendance> list=attendanceMapper.selTeaById(id);
        return list;
    }
    /**
     * @author TSY
    //  * @param 按照名字查询单个学生出勤记录
     */
    public List<Attendance> getStuByName(String name) {
        List<Attendance> list=attendanceMapper.selStudentByName(name);
        return list;
    }
    /**
     * @author TSY
    //  * @param 按照id查询单个学生出勤记录
     */
    public List<Attendance> getStuById(String name) {
        List<Attendance> list=attendanceMapper.selStudentById(name);
        return list;
    }
    /**
     * @author TSY
    //  * @param 查询所有学生出勤记录
     */
    public List<Attendance> getStuAll() {
        List<Attendance> list =attendanceMapper.selectAtt("2");
        return list;
    }
    /**
     * @author TSY
    //  * @param 按照课程查询所有学生出勤记录
     */
    public List<Attendance> getLessStuAll(String lessonsId) {
        List<Attendance> list =attendanceMapper.selectByLessons(lessonsId);
        return list;
    }
    /**
     * @author TSY
    //  * @param 按照课程查询所有学生出勤记录
     */
    public List<Attendance> getByClasssAndGrade(String grade,String classs) {
        List<Attendance> list =attendanceMapper.selectByClasssAndGrade(grade,classs);
        return list;
    }
    /**
     * @author TSY
    //  * @param 查询年级
     */
    public List<Attendance> getGrade() {
        List<Attendance> list =attendanceMapper.selectGrade();
        return list;
    }
    /**
     * @author TSY
    //  * @param 按照查询班级
     */
    public List<Attendance> getClasss(String grade) {
            return attendanceMapper.selectClasss(grade);
    }
    /**
     * @author TSY
    //  * @param 查询班级
     */
    public List<Attendance> getcClasss() {
        return attendanceMapper.selClasss();
    }


}
